Skip to content

fix: openrouter free model filtering#16098

Open
vorahardik7 wants to merge 1 commit intoanomalyco:devfrom
vorahardik7:fix/openrouter-catalog
Open

fix: openrouter free model filtering#16098
vorahardik7 wants to merge 1 commit intoanomalyco:devfrom
vorahardik7:fix/openrouter-catalog

Conversation

@vorahardik7
Copy link

Issue for this PR

Closes #15962

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode was showing some OpenRouter :free models that were not actually available for the connected account, which led to runtime errors like No endpoints found ....

This change updates OpenRouter model filtering to:

  • fetch the user-specific catalog from /models/user
  • keep only models available in that catalog (default behavior)
  • support tier filtering:
    • tier: "free" => show only free models
    • tier: "paid" => hide free models
    • tier: "any" => show both (default)
  • free_only: true (which was there earlier) still works and behaves like tier: "free".

This now filters by what OpenRouter says the current user can route to, instead of only relying on static model list from models.dev.

How did you verify your code works?

Ran locally:

  • Tested connecting to OpenRouter through my API key and checking the free models occurring now which is a correct list of models and tried sending requests.
  • cd packages/opencode && bun run typecheck
  • cd packages/opencode && bun test test/provider/provider.test.ts

Added/updated tests for:

  • user catalog filtering for OpenRouter
  • free tier filtering
  • paid tier filtering

Screenshots / recordings

N/A (no UI changes)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model unavailable

1 participant